/*
 *  Copyright (C) 2009  Peter Kist & Jan Ripke
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "MenuFactory.h"

#include <CEGUISystem.h>
#include <CEGUIRenderer.h>

#include <core/Logger.h>
#include <gfx/ogre/gui/Menu.h>
#include <gfx/ogre/menu/MainMenu.h>
#include <gfx/ogre/menu/CreditsMenu.h>
#include <gfx/ogre/menu/SettingsMenu.h>

namespace galaxy {
    namespace gfx {
        namespace ogre3d {
            namespace gui {

            MenuFactory::MenuFactory(void)
            {
            }

            MenuFactory::~MenuFactory(void)
            {
            }

            /** create object of specified type. The type is specified by name.
            * @param menuName the name for the menu (classname)
            * @return a valid shared menu pointer upon success or an empty shared pointer upon failure
            */
            MenuPtr MenuFactory::createMenu (MenuManager& menuManager, gfx::Menu::Name& menuName) {
                MenuPtr menuPtr;

                LOG_TRACE (std::string ("creating menu ") + menuName);

                if (menuName == gfx::Menu::c_MainMenu) {
                    boost::shared_ptr<menu::MainMenu> mainmenu (new menu::MainMenu(menuManager));
                    menuPtr = mainmenu;
                }
                if (menuName == gfx::Menu::c_Credits) {
                    boost::shared_ptr<menu::CreditsMenu> creditsmenu (new menu::CreditsMenu(menuManager));
                    menuPtr = creditsmenu;
                }
                if (menuName == gfx::Menu::c_Settings) {
                    boost::shared_ptr<menu::SettingsMenu> settingsmenu (new menu::SettingsMenu(menuManager));
                    menuPtr = settingsmenu;
                }

                return menuPtr;
            }

            } // namespace gui
        } // namespace ogre3d
    } // namespace gfx
} // namespace galaxy
